package com.ruoyi.park.service.impl;

import java.util.List;
import com.ruoyi.common.core.utils.DateUtils;
import cn.hutool.core.util.IdUtil;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.common.core.utils.SecurityUtils;
import com.ruoyi.park.mapper.WySupplierMapper;
import com.ruoyi.park.domain.WySupplier;
import com.ruoyi.park.service.IWySupplierService;

/**
 * 供应商Service业务层处理
 *
 * @author cjie
 * @date 2021-12-04
 */
@Service
public class WySupplierServiceImpl implements IWySupplierService {
    @Autowired
    private WySupplierMapper wySupplierMapper;

    /**
     * 查询供应商
     *
     * @param id 供应商ID
     * @return 供应商
     */
    @Override
    public WySupplier selectWySupplierById(String id) {
        return wySupplierMapper.selectWySupplierById(id);
    }

    /**
     * 查询供应商列表
     *
     * @param wySupplier 供应商
     * @return 供应商
     */
    @Override
    public List<WySupplier> selectWySupplierList(WySupplier wySupplier) {
        return wySupplierMapper.selectWySupplierList(wySupplier);
    }

    /**
     * 新增供应商
     *
     * @param wySupplier 供应商
     * @return 结果
     */
    @Override
    public int insertWySupplier(WySupplier wySupplier) {
        wySupplier.setId(IdUtil.getSnowflake(0, 0).nextIdStr());
        wySupplier.setCreateTime(DateUtils.getNowDate());
        wySupplier.setCreateBy(SecurityUtils.getUsername());
        return wySupplierMapper.insertWySupplier(wySupplier);
    }

    /**
     * 修改供应商
     *
     * @param wySupplier 供应商
     * @return 结果
     */
    @Override
    public int updateWySupplier(WySupplier wySupplier) {
        return wySupplierMapper.updateWySupplier(wySupplier);
    }

    /**
     * 批量删除供应商
     *
     * @param ids 需要删除的供应商ID
     * @return 结果
     */
    @Override
    public int deleteWySupplierByIds(String[] ids) {
        return wySupplierMapper.deleteWySupplierByIds(ids);
    }

    /**
     * 删除供应商信息
     *
     * @param id 供应商ID
     * @return 结果
     */
    @Override
    public int deleteWySupplierById(String id) {
        return wySupplierMapper.deleteWySupplierById(id);
    }
}
